<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function add(a, b) {
            return a + b;
        }
        function sub(a, b) {
            return a - b;
        }
        var a1 = add.apply(sub, [4, 2]);　　//sub调用add的方法
        var a2 = sub.apply(add, [4, 2]);
        console.log(a1);  //6     
        console.log(a2);  //2
         console.log(add)
        /*call的用法*/
        var a1 = add.call(sub, 4, 2);


        var a={}
        console.log(a)
    </script>
</body>

</html>